let temperatures = [73,74,75,71,69,72,76,73]
//维护一个单调递减的栈
//[0,0,0,0,0,0,0,0]
//[1,1,0,0,0,0,0,0]
var dailyTemperatures = function(temperatures) {
    const len = temperatures.length;
    const stack = [];
    const res = (new Array(len)).fill(0);
    for(let i = 0; i < len; i++) {
        //temperatures[i]
        //stack[stack.length - 1] 栈顶 数组的下标
        while(stack.length && temperatures[i] > temperatures[stack[stack.length - 1]]) {
            const top = stack.pop();
            res[top] = i - top;
        }
        stack.push(i);
    }
    return res;
}